<?php
    function __autoload($className)
    {
        $classPath = dirname(__DIR__) . '/';
        $className = explode('\\', $className);
        switch(count($className))
        {
            case 2:
                if($className[0] == 'framework')
                {
                    $classPath .= 'vixenworks/classes';
                }
                else
                {
                    $classPath .= 'modules';
                }
                $classNameKey = 1;
                break;
            case 3:
                $classPath .= 'model/' . $className[1];
                $classNameKey = 2;
                break;
            default:
                $classPath .= 'classes';
                $classNameKey = 0;
                break;
        }
        $classFile = $classPath . '/' . $className[$classNameKey] . '.php';
        include($classFile);
    }
    $session = new framework\session();
    if($session -> userLogin === false)
    {
        $requestedModule = 'system';
        $requestedAction = 'login';
    }
    else
    {
        if(isset($_GET['module']))
        {
            $requestedModule = $_GET['module'];
            if(isset($_GET['action']))
            {
                $requestedAction = $_GET['action'];
            }
            else
            {
                $requestedAction = 'default';
            }
        }
        else
        {
            $requestedModule = $requestedAction = 'default';
        }
    }
    $moduleClassName = 'modules\\' . $requestedModule;
    $module = new $moduleClassName();
    $module -> $requestedAction();
    $title = framework\project::getInstance() -> name;
    $view = $requestedModule . '/' . $requestedAction;
    foreach($module -> getViewVariables() as $variableName => $variableValue)
    {
        $$variableName = $variableValue;
    }
    $content = framework\project::getInstance() -> viewsPath . $view . '.php';
    include(framework\project::getInstance() -> layoutsPath . 'default.php');